/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package basan.components;

import basan.core.GameObject;
import basan.world.BasanWorld;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;

/**
 *
 * @author Menno @ Basans
 */
public class RenderPlaneComponent implements IComponent {

    private GameObject parent;
    private String tex;
    private Object3D plane;

    public RenderPlaneComponent(GameObject parent, String textureName) {
        this.parent = parent;
        this.tex = textureName;
        init();
    }
    
    public RenderPlaneComponent(GameObject parent, String textureName, String texturePath) {
        this.parent = parent;
        this.tex = textureName;
        //Path: "resource/<name>.<ext>"
        TextureManager.getInstance().addTexture(textureName, new Texture(texturePath));
        init();
    }
    
    public void init() {
        plane = Primitives.getPlane(10, 30f);
        plane.setTexture(tex);
        plane.setEnvmapped(Object3D.ENVMAP_ENABLED);
        
        //Start location
        plane.rotateX(90);
        plane.translate(parent.getLocation().getSimpleVector());
        
        plane.build();
        BasanWorld.world.addObject(plane);
    }
    
    @Override
    public void think() {
       
    }

    @Override
    public void update() {
        
    }

    @Override
    public void lateUpdate() {
        
    }
    
}
